package ddn.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import ddn.model.Gender;
import ddn.model.UserProfile;
import ddn.v1.R;

public class ShowRegisterActivity extends Activity {

	private static final String TAG = "ShowRegisterActivity";

	private EditText reg_login;
	private EditText reg_passwd;
	private EditText reg_passwd2;
	private EditText reg_name;
	private EditText reg_firstname;
	private EditText reg_birthday;
	private RadioButton reg_male;
	private RadioButton reg_female;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.register);

		// getting register form elements
		reg_login = (EditText) findViewById(R.id.et_reg_login);
		reg_passwd = (EditText) findViewById(R.id.et_reg_passwd);
		reg_passwd2 = (EditText) findViewById(R.id.et_reg_passwd2);
		reg_name = (EditText) findViewById(R.id.et_reg_name);
		reg_firstname = (EditText) findViewById(R.id.et_reg_firstname);
		reg_birthday = (EditText) findViewById(R.id.et_reg_birthday);
		reg_male = (RadioButton) findViewById(R.id.radio_reg_male);
		reg_female = (RadioButton) findViewById(R.id.radio_reg_female);

		findViewById(R.id.bt_reg_saveReg).setOnClickListener(
		// Onclick listener attached to bt_reg_saveReg
				new Button.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Validate fields
						Gender g;
						if (reg_male.isChecked()) {
							g = Gender.Male;
						} else {
							g = Gender.Female;
						}
						UserProfile up = new UserProfile(reg_login.getText()
								.toString(), reg_passwd.getText().toString(),
								reg_name.getText().toString(), reg_firstname
										.getText().toString(), reg_birthday
										.getText().toString(), g);
						Log.i(TAG, up.toString());
					}

				});

		reg_male.setOnClickListener(new RadioButton.OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i(TAG, "reg_male pinchado");
			};
		});
		
		reg_female.setOnClickListener(new RadioButton.OnClickListener() {

			@Override
			public void onClick(View v) {
				Log.i(TAG, "regfe_male pinchado");
			};
		});
	}
	

}